from django.db import models


class KuaishouVideo(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    video_id = models.CharField(max_length=64, verbose_name='视频ID', unique=True)
    video_type = models.CharField(max_length=16, verbose_name='视频类型')
    title = models.CharField(max_length=500, null=True, blank=True, verbose_name='视频标题')
    desc = models.TextField(verbose_name='视频描述')
    create_time = models.BigIntegerField(verbose_name='视频发布时间戳')
    liked_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频点赞数')
    viewd_count = models.CharField(max_length=16, null=True, blank=True, verbose_name='视频浏览数量')
    video_url = models.CharField(max_length=512, null=True, blank=True, verbose_name='视频详情URL')
    video_cover_url = models.CharField(max_length=512, null=True, blank=True, verbose_name='视频封面图 URL')
    video_play_url = models.CharField(max_length=512, null=True, blank=True, verbose_name='视频播放 URL')
    source_keyword = models.CharField(max_length=255, default='', verbose_name='搜索来源关键字')
    task_id = models.CharField(max_length=255, verbose_name='任务ID', null=True, blank=True)
    class Meta:
        db_table = 'kuaishou_video'
        verbose_name = '快手视频'
        indexes = [
            models.Index(fields=['video_id'], name='idx_kuaishou_vi_video_i_c5c6a6'),
            models.Index(fields=['create_time'], name='idx_kuaishou_vi_create__a10dee'),
        ]


class KuaishouVideoComment(models.Model):
    user_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户ID')
    nickname = models.CharField(max_length=64, null=True, blank=True, verbose_name='用户昵称')
    avatar = models.CharField(max_length=255, null=True, blank=True, verbose_name='用户头像地址')
    add_ts = models.BigIntegerField(verbose_name='记录添加时间戳')
    last_modify_ts = models.BigIntegerField(verbose_name='记录最后修改时间戳')
    comment_id = models.CharField(max_length=64, verbose_name='评论ID')
    video_id = models.ForeignKey(
        KuaishouVideo,
        to_field='video_id',
        db_column='video_id',
        on_delete=models.CASCADE,
        related_name='comments',
        verbose_name='视频关联',
        null=True,
        blank=True,
    )
    content = models.TextField(verbose_name='评论内容')
    create_time = models.BigIntegerField(verbose_name='评论时间戳')
    sub_comment_count = models.CharField(max_length=16, verbose_name='评论回复数')
    parent_comment_id = models.CharField(max_length=64, null=True, blank=True, verbose_name='父评论ID')
    like_count = models.IntegerField(default=0, verbose_name='点赞数')

    class Meta:
        db_table = 'kuaishou_video_comment'
        verbose_name = '快手视频评论'
        indexes = [
            models.Index(fields=['comment_id'], name='idx_kuaishou_vi_comment_ed48fa'),
            models.Index(fields=['video_id'], name='idx_kuaishou_vi_video_i_e50914'),
        ]
